package com.ywx.yypicturebackend.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/**
 * 空间等级枚举类
 */
@Getter
public enum SpaceLevelEnum {
    COMMON("普通版", 0, 100L * 1024 * 1024, 100L),
    PROFESSIONAL("专业版", 1, 1000L * 1024 * 1024,1000L ),
    FLAGSHIP("旗舰版", 2, 10000L * 1024 * 1024,10000L );


    private String context;
    private int level;
    private Long maxSize;
    private Long maxCount;

    SpaceLevelEnum(String context, int level, Long maxSize, Long maxCount) {
        this.context = context;
        this.level = level;
        this.maxSize = maxSize;
        this.maxCount = maxCount;
    }

    /**
     * 根据Value获取枚举
     * @param value
     * @return
     */
    public static SpaceLevelEnum getEnumByValue(Integer value) {

        if (ObjUtil.isEmpty(value)) {
            return null;
        }

        for (SpaceLevelEnum spaceLevelEnum : SpaceLevelEnum.values()) {
            if(value.equals(spaceLevelEnum.getLevel())){
                return spaceLevelEnum;
            }
        }

        return null;
    }



}
